home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performRebuildCurveSet.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.7 KB  |  153 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 14, 1997
  22. //  Author:         laf 
  23. //
  24. //  Description:
  25. //      This script runs rebuild curve on the selection list.
  26. //
  27.  
  28.  
  29. global proc performRebuildCurveSet( int $doHistory, int $replaceOriginal,
  30.                                     int $rebuildType, float $globalTol,
  31.                                     int $crvNumSpans, int $crvDegree,
  32.                                     int $endKnots,
  33.                                     int $keepParmRange, int $keepControlPoints,
  34.                                     int $keepEndPts, int $keepTan,
  35.                                     int $crvUseGlobalTol, float $crvLocalTol)
  36. {
  37.     // Get a list of each type of acceptable object type - 
  38.     // curves, and curves-on-surface.
  39.     //
  40.     global int $gSelectNurbsCurvesBit;
  41.     global int $gSelectCurvesOnSurfacesBit;
  42.     string $curveList[] = `filterExpand -ex true -sm $gSelectNurbsCurvesBit`;
  43.     string $cosList[] = `filterExpand -ex true -sm $gSelectCurvesOnSurfacesBit`;
  44.  
  45.     int $i;
  46.  
  47.     if( $rebuildType == 2 ) {
  48.         if( (size($curveList) + size($cosList)) < 2 ) {
  49.             error( "Select at least two NURBS curves to " +
  50.                    "rebuild with match knots option.") ;
  51.             return;
  52.         }
  53.     }
  54.     else {
  55.         if( (size($curveList) + size($cosList)) < 1 ) {
  56.             error( "Nothing was selected to rebuild.  You must select " +
  57.                    "NURBS curves or curve on surfaces.");
  58.             return;
  59.         }
  60.     }
  61.  
  62.     // Execute rebuildCurve on all active curves.
  63.     //
  64.     $cmd = "rebuildCurve" + " -ch " + $doHistory + 
  65.            " -rpo " + $replaceOriginal+
  66.            " -rt " + $rebuildType + 
  67.            " -end " + $endKnots +
  68.            " -kr " + $keepParmRange +
  69.            " -kcp " + $keepControlPoints +
  70.            " -kep " + $keepEndPts + 
  71.            " -kt " + $keepTan;
  72.     $cmd += " -s " + $crvNumSpans + " -d " + $crvDegree;
  73.     if( $crvUseGlobalTol == 0 ) {    // Use globl tolerance vs. local tolerance
  74.         $cmd += " -tol " + $crvLocalTol;
  75.     } else {
  76.         $cmd += " -tol " + $globalTol;
  77.     }
  78.  
  79.     string $cosCmd;
  80.     $cosCmd = $cmd;
  81.  
  82.     string $curveResults[] ;
  83.  
  84.     if( $rebuildType == 2 ) {
  85.         int $l = size($curveList) ;
  86.         if( $l > 2 ) {
  87.             warning( "Rebuilding all but the last curve to match knots " +
  88.                      "of the last curve in the selection list" );
  89.         }
  90.         if( $l >= 2 ) {
  91.             int $nitems = 2 ;
  92.             $cmd = appendToCmdPlaceHoldersForSelectionItems( $cmd, $nitems ) ;
  93.             string $curvePair[2] ;
  94.  
  95.             for( $i=0; $i<($l-1); $i+=1 ) {
  96.                 $curvePair[0] = $curveList[$i] ;    
  97.                 $curvePair[1] = $curveList[$l-1];
  98.                 string $oneRes[] = executeCmdOnItems($cmd,$curvePair);
  99.                 appendStringArray( $curveResults, $oneRes, size($oneRes));
  100.             }
  101.         }
  102.     } else {
  103.         $cmd += " %s;";
  104.         $curveResults = executeForEachObject( $curveList, $cmd );
  105.     }
  106.  
  107.     // Execute rebuildCurve on all active curves-on-surface.
  108.     //
  109.     // $cosCmd +=  " -cos on ";
  110.     string $cosResults[];
  111.     if( $rebuildType == 2 ) {
  112.         int $l = size($cosList) ;
  113.         if( $l > 2 ) {
  114.             warning( "Rebuilding all but the last curve to match knots " +
  115.                      "of the last curve in the selection list" );
  116.         }
  117.         if( $l >= 2  ) {
  118.             int $nitems = 2 ;
  119.             $cosCmd = appendToCmdPlaceHoldersForSelectionItems( $cosCmd, $nitems ) ;
  120.             for( $i=0; $i<($l-1); $i+=1 ) {
  121.                 $curvePair[0] = $cosList[$i] ;    
  122.                 $curvePair[1] = $cosList[$l-1];
  123.                 string $oneRes[] = executeCmdOnItems($cmd,$curvePair);
  124.                 appendStringArray( $curveResults, $oneRes, size($oneRes));
  125.             }
  126.         }
  127.     } else {
  128.         $cosCmd += " %s;" ;
  129.         $cosResults = executeForEachObject( $cosList, $cosCmd );
  130.     }
  131.  
  132.  
  133.     if( (size($curveResults)+size($cosResults)) == 0 ) {
  134.         int $l = size($curveList) ;
  135.         if( $rebuildType == 2  && (size($curveList) < 2) ) {
  136.             error( "Select at least two NURBS curves to rebuild " +
  137.                    "with match knots.");
  138.         }
  139.         else if( 0 == (size($curveList) + size($cosList)) ) {
  140.             error( "Nothing was selected to rebuild.  You must select " +
  141.                    "NURBS curves.");
  142.         }
  143.         else {
  144.             error( "Rebuild curve failed on the current valid selection." );
  145.         }
  146.     } else {
  147.         // Select all the results with one select command
  148.         //
  149.         select -r $curveResults $cosResults;
  150.     }
  151. }
  152.  
  153.